define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'club/ordinaryuser/index',
                    table: 'c_user',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search: false,
                columns: [
                    [
                        {field: 'id', title: __('Id')},
                        {field: 'clubid', title: __('clubid')},
                        {field: 'uid', title: __('uid')},
                        {field: 'honorscore', title: __('honorscore')},
                    ]
                ]
            });
            
            //指定搜索条件
            var clubidval = $("#clubid").text();  
            var options = table.bootstrapTable('getOptions');
            options.pageNumber = 1;
            options.queryParams = function (params) {
                return {
                    search: params.search,
                    sort: params.sort,
                    order: params.order,
                    filter: JSON.stringify({clubid: clubidval}),
                    op: JSON.stringify({clubid: '='}),
                    offset: params.offset,
                    limit: params.limit,
                };
            };
            table.bootstrapTable('refresh', {});

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});